<?php
namespace app\admin\controller;

use app\admin\controller\Base;
use app\admin\model\Menu;
use app\admin\model\Role;
use app\admin\model\Admin;

class Index extends Base
{
    /*
     * 后台首页
     */
    public function index()
    {
        $user = $this->user_info();
        //查询当前用户的角色
        $roles = Role::where(array("r_id"=>$user['roles_id']))->find();
        $menu = Menu::where(array("pid"=>0,'status'=>1,"id"=>array("in",$roles['jurisdiction'])))->order("sort asc")->select();
        
        $menu = collection($menu)->toArray();

        foreach($menu as $key=>$val){
            $menuTow = Menu::where(array('pid'=>$val['id'],'status'=>1,"id"=>array("in",$roles['jurisdiction'])))->order("sort asc")->select();
            $menu[$key]['menuTow'] = collection($menuTow)->toArray();
        }
        
        $data = array(
            "setting" => $this->getAllSetting(),
            "list" =>$menu,
            "user"=>$user
        );
        return view('index',$data);
    }
}
